<?php
namespace app\admin\controller;

use app\common\model\EvaluatieQuestions;
use think\facade\View;

class EvalQuestions extends Base
{
    public function index($dataType=0)
    {
        //问卷列表
        $queModel=new EvaluatieQuestions();
        $queData=$queModel->dataList(EvaluatieQuestions::class,["data_type"=>$dataType],0,1,'id asc');
        View::assign("breadcrumb",["oneTitle"=>"问卷管理","twoTitle"=>"问卷列表"]);
        View::assign("questions",$queData);
        View::assign("dataType",$dataType);
        return View::fetch("questions/index");
    }

    public function editSave(){
        $queModel=new EvaluatieQuestions();
        $dataType=input('dataType');
        $qu_msg=input('qu_msg');
        $qu_id=input('qu_id');
        $qu_score=input('qu_score');
        for($i=0;$i<count($qu_id);$i++){
            $update=[
                "qu_score"=>$qu_score[$i],
                "qu_msg"=>$qu_msg[$i]
            ];
            $queModel->updateOne(EvaluatieQuestions::class,$update,["id"=>$qu_id[$i]]);
        }
        return redirect('/admin/questions/index?dataType='.$dataType);
    }
}
